﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DTO;

namespace GUI
{
    public partial class frmXemHop : Form
    {
        public frmXemHop()
        {
            InitializeComponent();
        }

        private void frmXemHop_Load(object sender, EventArgs e)
        {
            LayDanhSach();
        }

        void LayDanhSach()
        {
            List<ChuyenThuDTO> ds = new List<ChuyenThuDTO>();
            ChuyenThuBUS bus = new ChuyenThuBUS();
            ds = bus.LayThongTinCT();
            int stt = 1;
            dgvDanhSach.Rows.Clear();
            for (int i = 0; i <= ds.Count - 1; i++)
            {
                string TinhTrang = "Đang thu";
                if (ds[i].MATT == 5)
                    TinhTrang = "Hoàn tất";

                dgvDanhSach.Rows.Add(stt, ds[i].MaDH, ds[i].MaMA, ds[i].NgayGioTH, TinhTrang, ds[i].MaNVTH, ds[i].SLHopThu, ds[i].SLHopThieu);
                stt++;
            }
        }

        void LayDanhSachDangThu()
        {
            List<ChuyenThuDTO> ds = new List<ChuyenThuDTO>();
            ChuyenThuBUS bus = new ChuyenThuBUS();
            ds = bus.LietKeDonHangDangThu();
            int stt = 1;
            dgvDanhSach.Rows.Clear();
            for (int i = 0; i <= ds.Count - 1; i++)
            {
                string TinhTrang = "Đang thu";
                if (ds[i].MATT == 5)
                    TinhTrang = "Hoàn tất";

                dgvDanhSach.Rows.Add(stt, ds[i].MaDH, ds[i].MaMA, ds[i].NgayGioTH, TinhTrang, ds[i].MaNVTH, ds[i].SLHopThu, ds[i].SLHopThieu);
                stt++;
            }
        }

        void LayDanhSachHoanTat()
        {
            List<ChuyenThuDTO> ds = new List<ChuyenThuDTO>();
            ChuyenThuBUS bus = new ChuyenThuBUS();
            ds = bus.LietKeDonHangHoanTat();
            int stt = 1;
            dgvDanhSach.Rows.Clear();
            for (int i = 0; i <= ds.Count - 1; i++)
            {
                string TinhTrang = "Đang thu";
                if (ds[i].MATT == 5)
                    TinhTrang = "Hoàn tất";

                dgvDanhSach.Rows.Add(stt, ds[i].MaDH, ds[i].MaMA, ds[i].NgayGioTH, TinhTrang, ds[i].MaNVTH, ds[i].SLHopThu, ds[i].SLHopThieu);
                stt++;
            }
        }

        private void btnXem_Click(object sender, EventArgs e)
        {
            if (cbbLoc.SelectedItem.ToString() == "Tất cả")
                LayDanhSach();
            else
                if (cbbLoc.SelectedItem.ToString() == "Đang thu")
                    LayDanhSachDangThu();
                else
                    LayDanhSachHoanTat();
          
        }


    
    }
}
